package create.prototye;

/**
 * @author lzp
 * @Date:2023/2/24
 * @description: Student本身就是原型，copy方法用于拷贝构造新的Student对象
 */
public class Student {

	/**
	 * 名称
	 */
	private String name;

	/**
	 * 年龄
	 */
	private int age;

	/**
	 * 性别
	 */
	private int sex;


	/**
	 * 拷贝生成一个新对象
	 */
	public Student copy() {
		Student student = new Student();
		student.setAge(this.getAge());
		student.setName(this.getName());
		student.setSex(this.getSex());
		return student;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}
}
